package com.zlj.springcloud.cfgbean;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import com.netflix.loadbalancer.RetryRule;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * @Description: SpringBoot配置类
 * @Author: zlj
 * @CreateDate: 2018/6/19 11:49
 * @Version: 1.0.0
 */
@Configuration
public class ConfigBean {

    @LoadBalanced
    @Bean
    public RestTemplate getRestTemplate() {
        return new RestTemplate();
    }

    /**
     * 默认是轮询算法
     * @return
     */
    @Bean
    public IRule getIRule() {
        //return new RandomRule();      //修改为随机算法
        return new RetryRule();
    }
}
